package com.tstudy.laoshibang.base;

import java.io.File;
import java.util.List;

import com.google.gson.Gson;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.PersistentCookieStore;
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.ResponseHandlerInterface;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
import com.nostra13.universalimageloader.core.decode.BaseImageDecoder;
import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import com.nostra13.universalimageloader.utils.StorageUtils;
import com.tstudy.laoshibang.mode.Address;
import com.tstudy.laoshibang.mode.DicMap;
import com.tstudy.laoshibang.mode.request.ActiveApplyParams;
import com.tstudy.laoshibang.mode.request.ActiveCategoryParams;
import com.tstudy.laoshibang.mode.request.ActiveDetailParams;
import com.tstudy.laoshibang.mode.request.BindMobileParams;
import com.tstudy.laoshibang.mode.request.CommentListParams;
import com.tstudy.laoshibang.mode.request.CommonAdsListParams;
import com.tstudy.laoshibang.mode.request.CommonListParams;
import com.tstudy.laoshibang.mode.request.CommunityDetailParams;
import com.tstudy.laoshibang.mode.request.CommunityListParams;
import com.tstudy.laoshibang.mode.request.Conds;
import com.tstudy.laoshibang.mode.request.CreateCommentParams;
import com.tstudy.laoshibang.mode.request.CreateCommunityParams;
import com.tstudy.laoshibang.mode.request.DeleteCommentParams;
import com.tstudy.laoshibang.mode.request.DeleteComnunityParams;
import com.tstudy.laoshibang.mode.request.FeedbackParams;
import com.tstudy.laoshibang.mode.request.GetValidateNoParams;
import com.tstudy.laoshibang.mode.request.GroupProfileParams;
import com.tstudy.laoshibang.mode.request.GroupSelectParams;
import com.tstudy.laoshibang.mode.request.LoginParams;
import com.tstudy.laoshibang.mode.request.LoveActionParams;
import com.tstudy.laoshibang.mode.request.MessageListParams;
import com.tstudy.laoshibang.mode.request.MessageReadParams;
import com.tstudy.laoshibang.mode.request.ModifyPasswordParams;
import com.tstudy.laoshibang.mode.request.MyCommunityListParams;
import com.tstudy.laoshibang.mode.request.PushBindParams;
import com.tstudy.laoshibang.mode.request.QueryAddressParams;
import com.tstudy.laoshibang.mode.request.QuerySchoolParams;
import com.tstudy.laoshibang.mode.request.RegistParams;
import com.tstudy.laoshibang.mode.request.ResetPasswordParams;
import com.tstudy.laoshibang.mode.request.SysMessageReadParams;
import com.tstudy.laoshibang.mode.request.ThirdLoginParams;
import com.tstudy.laoshibang.mode.request.UpdateUserDicParams;
import com.tstudy.laoshibang.mode.request.UpdateUserIntegerParams;
import com.tstudy.laoshibang.mode.request.UpdateUserParams;
import com.tstudy.laoshibang.mode.request.UpdateUserStringParams;
import com.tstudy.laoshibang.mode.request.UserNoParams;
import com.tstudy.laoshibang.mode.request.ViewActionParams;
import com.tstudy.laoshibang.mode.request.WeikeDetailParams;
import com.tstudy.laoshibang.utils.CommonUtil;
import com.tstudy.laoshibang.utils.LogUtil;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
/**
 * 网络请求管理类
* @CopyRight weitaming.com
* @author wuyahui
* @E-mail wuyahui@ispied.com
* @version 1.0.0
* @Date 2014年4月29日 下午5:47:25
 */
public class HttpManager {
	private static HttpManager mO2OHttpManager = new HttpManager();

	public static PersistentCookieStore mCookiStore;
	private static AsyncHttpClient mAsyncHttpClient;
	private static ImageLoader mImageLoader;
	private static DisplayImageOptions mOptions;
	private static DisplayImageOptions mRawOptions;
	private static DisplayImageOptions mloadAvatarOptions;
	private static DisplayImageOptions mloadEditAvatarOptions;
	private static Gson mGson;
	private HttpManager() {
		mGson = new Gson();
	}
	

	public static HttpManager getInstance() {
		return mO2OHttpManager;
	}
	public void initHttpInfo() {
//		LogUtil.d("---getCacheDir ==" + BaseApplication.mContext.getCacheDir());
//		LogUtil.d("---getExternalCacheDir==" + BaseApplication.mContext.getExternalCacheDir().getPath());
//		LogUtil.d("---getFilesDir==" + BaseApplication.mContext.getFilesDir().getPath());
//		LogUtil.d("---getExternalFilesDir==" + BaseApplication.mContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath());
		initImageLoader();
		mAsyncHttpClient = new AsyncHttpClient();
		mAsyncHttpClient.addHeader("equipId",CommonUtil.getIMEI());
		mAsyncHttpClient.setTimeout(1000 * 30);
		mCookiStore = new PersistentCookieStore(BaseApplication.mContext);
		mAsyncHttpClient.setCookieStore(mCookiStore);
	}

	public static AsyncHttpClient getAsyncHttpClient() {
		return mAsyncHttpClient;
	}
	
	private static void initImageLoader() {
		File cacheDir = StorageUtils.getCacheDirectory(BaseApplication.mContext);
		LogUtil.d("---initImageLoader cacheDir==" + cacheDir.getPath());
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				BaseApplication.mContext)
				.memoryCacheExtraOptions(480, 800)
				// default = device screen dimensions
				.discCacheExtraOptions(480, 800, CompressFormat.PNG, 75, null)
				// .taskExecutor(...)
				// .taskExecutorForCachedImages(...)
				.threadPoolSize(3)
				// default
				.threadPriority(Thread.NORM_PRIORITY - 1)
				// default
				.tasksProcessingOrder(QueueProcessingType.FIFO)
				// default
				.denyCacheImageMultipleSizesInMemory()
//				.memoryCache(new LruMemoryCache(5 * 1024 * 1024))
//				.memoryCacheSize(5 * 1024 * 1024)
				.memoryCacheSizePercentage(10)
				// default
				.discCache(new UnlimitedDiscCache(cacheDir))
				// default
				.discCacheSize(500 * 1024 * 1024)
				.discCacheFileCount(300)
				.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
				// default
				.imageDownloader(new BaseImageDownloader(BaseApplication.mContext)) // default
				.imageDecoder(new BaseImageDecoder(true)) // default
				.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
				.writeDebugLogs().build();
			mImageLoader = ImageLoader.getInstance();
			mImageLoader.init(config);
			mOptions = new DisplayImageOptions.Builder()
//				.showImageOnLoading(R.drawable.browse_pic_loading) // resource drawable
//				.showImageForEmptyUri(R.drawable.browse_pic_loading) // resource drawable
//				.showImageOnFail(R.drawable.browse_pic_loading) // resource or drawable
				.resetViewBeforeLoading(false) // default
				// .delayBeforeLoading(1000)
				.cacheInMemory(true).cacheOnDisc(true)
				// .preProcessor(...)
				// .postProcessor(...)
				// .extraForDownloader(...)
				.considerExifParams(false) // default
				.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
				.bitmapConfig(Bitmap.Config.ARGB_8888) // default
				// .decodingOptions(...)
				// .displayer(new SimpleBitmapDisplayer()) // default
				// .handler(new Handler()) // default
				.build();
			mloadAvatarOptions = new DisplayImageOptions.Builder()
			.resetViewBeforeLoading(false) // default
			.cacheInMemory(true).cacheOnDisc(true)
			.considerExifParams(false) // default
			.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
			.bitmapConfig(Bitmap.Config.RGB_565) // default
			.build();
			mRawOptions = new DisplayImageOptions.Builder()
			.cacheOnDisc(true)
			.cacheInMemory(true)
//			.bitmapConfig(Bitmap.Config.ARGB_8888)
			.build();
	}

	public void loadCommonImage(ImageView imageView, String image_url) {
		loadCommonImage(imageView, image_url, null);
	}
	
	public void loadCommonImage(ImageView imageView, String image_url,ImageLoadingListener listener) {
		imageView.setImageBitmap(null);//
		mImageLoader.displayImage(image_url, imageView, mOptions,listener);
	}
	
	public void clearImageCache(){
		mImageLoader.clearDiscCache();
		mImageLoader.clearMemoryCache();
	}
	
	/**
	 * 获取头像的圆形图
	 * @param imageView
	 * @param image_url
	 * @param radius
	 */
	public void loadCircleImage(ImageView imageView, String image_url,final int radius) {
		loadCircleImage(imageView, image_url, radius, 0);
	}
	
	/**
	 * 获取头像的圆形图
	 * @param imageView
	 * @param image_url
	 * @param radius
	 */
	public void loadCircleImage(ImageView imageView, String image_url,final int radius,final int borderWidth) {
		imageView.setImageBitmap(null);//防止头像跳动
		mImageLoader.displayImage(image_url, imageView, mloadAvatarOptions,
				new SimpleImageLoadingListener() {
					@Override
					public void onLoadingStarted(String imageUri, View view) {
						// spinner.setVisibility(View.VISIBLE);
					}

					@Override
					public void onLoadingFailed(String imageUri, View view,
							FailReason failReason) {
					}

					@Override
					public void onLoadingComplete(String imageUri,
							View view, Bitmap loadedImage) {
						// spinner.setVisibility(View.GONE);
						if (radius > 0 && loadedImage != null) {
							if (borderWidth == 0) {
								((ImageView) view).setImageBitmap(CommonUtil.getCircleBitmap(loadedImage,radius));
							}else{
								((ImageView) view).setImageBitmap(CommonUtil.getCircleBitmap(loadedImage,radius));
							}
						}
					}
				});
	}
	
	
	public void loadCornerImage(ImageView imageView, String image_url,final int radius) {
		imageView.setImageBitmap(null);//防止头像跳动
		mImageLoader.displayImage(image_url, imageView, mloadAvatarOptions,
				new SimpleImageLoadingListener() {
					@Override
					public void onLoadingStarted(String imageUri, View view) {
					}

					@Override
					public void onLoadingFailed(String imageUri, View view,
							FailReason failReason) {
					}

					@Override
					public void onLoadingComplete(String imageUri,
							View view, Bitmap loadedImage) {
						if (radius > 0 && loadedImage != null) {
							((ImageView) view).setImageBitmap(CommonUtil.getRoundedCornerBitmap(loadedImage, radius));
						}
					}
				});
	}
	
	/**
	 * 加载编辑时的头像图片
	 * @param imageView
	 * @param image_url
	 * @param defaultImageRes
	 */
	public void loadEditAvatar(ImageView imageView, String image_url,int defaultImageRes){
		if (mloadEditAvatarOptions == null) {
			mloadEditAvatarOptions = new DisplayImageOptions.Builder()
			.showImageOnLoading(defaultImageRes) // resource drawable
			.showImageForEmptyUri(defaultImageRes) // resource drawable
			.showImageOnFail(defaultImageRes) // resource or drawable
			.resetViewBeforeLoading(false) // default
			.cacheInMemory(true).cacheOnDisc(true)
			.considerExifParams(false) // default
			.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
			.bitmapConfig(Bitmap.Config.RGB_565) // default
			.displayer(new RoundedBitmapDisplayer(10))
			.build();
		}
		loadImage(imageView, image_url, mloadEditAvatarOptions);
	}

	public void loadImage(ImageView imageView, String image_url,DisplayImageOptions displayImageOptions) {
		mImageLoader.displayImage(image_url, imageView, displayImageOptions);
	}
	
	
	public void loadRowImage(ImageView imageView, String image_url) {
//		imageView.setImageBitmap(null);
		mImageLoader.displayImage(image_url, imageView,mRawOptions);
	}
	
	
	public interface LoadImageViewResponse{
		void loadFinish(Bitmap bitmap);
	}
	public void downLoadImage(String url,final LoadImageViewResponse response) {
		mImageLoader.loadImage(url, new ImageLoadingListener() {
			@Override
			public void onLoadingStarted(String imageUri, View view) {
			}
			
			@Override
			public void onLoadingFailed(String imageUri, View view,
					FailReason failReason) {
			}
			
			@Override
			public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
				response.loadFinish(loadedImage);
			}
			
			@Override
			public void onLoadingCancelled(String imageUri, View view) {
			}
		});
	}
	
	/**
	 * @param code
	 * @param response
	 * { "access_token":"ACCESS_TOKEN", "expires_in":7200,
	 * "refresh_token":"REFRESH_TOKEN", "openid":"OPENID",
	 * "scope":"SCOPE" }
	 */
	public void getWechatAccessToken(String code,JsonHttpResponseHandler response){
		RequestParams params = new RequestParams();
		params.put("appid",CONSTANT.WECHAT_APP_ID);
		params.put("secret", CONSTANT.WECHAT_APP_SECRET);
		params.put("code",code);
		params.put("grant_type", "authorization_code");
		String url = "https://api.weixin.qq.com/sns/oauth2/access_token";
		mAsyncHttpClient.get(url, params, response);
	}
	
	
	/**
	 * refresh token
	 * 
	 * @param code
	 * @param response
	 * { "access_token":"ACCESS_TOKEN", "expires_in":7200,
	 * "refresh_token":"REFRESH_TOKEN", "openid":"OPENID",
	 * "scope":"SCOPE" }
	 */
	public void refreshWechatToken(String refreshToken,JsonHttpResponseHandler response){
		RequestParams params = new RequestParams();
		params.put("appid",CONSTANT.WECHAT_APP_ID);
		params.put("refresh_token",refreshToken);
		params.put("grant_type", "refresh_token");
		String url = "https://api.weixin.qq.com/sns/oauth2/refresh_token";
		mAsyncHttpClient.get(url, params, response);
	}
	
	/**
	 * 获取微信用户信息
	 * @param accessToken
	 * @param openId
	 * @param response
	 * { 
		"openid":"OPENID",
		"nickname":"NICKNAME",
		"sex":1,
		"province":"PROVINCE",
		"city":"CITY",
		"country":"COUNTRY",
		"headimgurl": "http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0",
		"privilege":[
		"PRIVILEGE1", 
		"PRIVILEGE2"
		],
		"unionid": " o6_bmasdasdsad6_2sgVt7hMZOPfL"
		}
	 */
	public void getWXUserInfo(String accessToken,String openId,JsonHttpResponseHandler response){
		RequestParams params = new RequestParams();
		params.put("access_token",accessToken);
		params.put("openid", openId);
		String url = "https://api.weixin.qq.com/sns/userinfo";
		mAsyncHttpClient.get(url, params, response);
	}
	
	

	/**
	 * 注册接口
	 * @param mobile
	 * @param password
	 * @param validateNo
	 * @param smsId
	 * @param response
	 */
	public void regist(String mobile, String password,String validateNo,String smsId,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.REGIST);
		RegistParams registParams = new RegistParams();
		registParams.setMobile(mobile);
		registParams.smsId = smsId;
		registParams.setPassword(CommonUtil.getMD5(password));
		registParams.setValidateNo(validateNo);
		registParams.setRole(CONSTANT.USER_ROLE_TEACHER);
		registParams.setMediaSource(CONSTANT.MEDIA_SOURCE_ANDROID);
		registParams.setEquipId(CommonUtil.getIMEI());
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(registParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 登陆
	 * @param mobile
	 * @param password
	 * @param response
	 */
	public void login(String mobile,String password,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.LOGIN);
		LoginParams loginParams = new LoginParams();
		loginParams.setLoginName(mobile);
		loginParams.setPassword(password);
		if (!TextUtils.isEmpty(BaseApplication.mPushUserId)) {
			loginParams.setTsUserId(BaseApplication.mPushUserId);
		}
		loginParams.setRole(CONSTANT.USER_ROLE_TEACHER);
		loginParams.setMediaSource(CONSTANT.MEDIA_SOURCE_ANDROID);
		loginParams.setEquipId(CommonUtil.getIMEI());
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(loginParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
		
	}
	
	/**
	 * 设置推送userId
	 * @param mobile
	 * @param 
	 */
	public void bindPush(boolean isBind,ResponseHandlerInterface response){
		String eventType = CONSTANT.EVENT_TYPE.PUSH_UNBIND;
		if (isBind) {
			eventType = CONSTANT.EVENT_TYPE.PUSH_BIND;
		}
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,eventType);
		PushBindParams entityParams = new PushBindParams();
		entityParams.userNo =BaseApplication.mUserNo;
		entityParams.tsUserId =BaseApplication.mPushUserId;
		entityParams.tsChannelId =BaseApplication.mPushChannelId;
		entityParams.mediaSource = CONSTANT.MEDIA_SOURCE_ANDROID;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	

	/**
	 * 获取短信验证码
	 * @param mobile
	 * @param type 注册或忘记密码
	 * @param response
	 */
	public void getValidateNo(String mobile,int type,ResponseHandlerInterface response){
		 RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.SEND_VALIDATE_CODE);
         GetValidateNoParams getValidateParams = new GetValidateNoParams();
         getValidateParams.setMobile(mobile);
         getValidateParams.setRole(CONSTANT.USER_ROLE_TEACHER);
         getValidateParams.setType(type);
         params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(getValidateParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 忘记密码 -验证
	 * @param mobile
	 * @param validateNo
	 * @param response
	 */
	public void resetPasswordValidate(String mobile,String validateNo,String smsId,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.RESET_PASSWORD_VALIDATE);
        ResetPasswordParams resetPasswordParams = new ResetPasswordParams();
        resetPasswordParams.setMobile(mobile);
        resetPasswordParams.smsId = smsId;
        resetPasswordParams.type = CONSTANT.VALIDATE_NO_TYPE_FORGET_PASSWORD;
        resetPasswordParams.setValidateNo(validateNo);
        resetPasswordParams.setRole(CONSTANT.USER_ROLE_TEACHER);
        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(resetPasswordParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 忘记密码 -更新
	 * @param mobile
	 * @param validateNo
	 * @param password
	 * @param response
	 */
	public void resetPassword(String mobile,String validateNo,String password,String smsId,ResponseHandlerInterface response){
		 RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.RESET_PASSWORD);
         ResetPasswordParams resetPasswordParams = new ResetPasswordParams();
         resetPasswordParams.setMobile(mobile);
         resetPasswordParams.smsId = smsId;
         resetPasswordParams.setPassword(CommonUtil.getMD5(password));
         resetPasswordParams.setValidateNo(validateNo);
         resetPasswordParams.setRole(CONSTANT.USER_ROLE_TEACHER);
         params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(resetPasswordParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 修改密码
	 * @param userNo
	 * @param oldPassword
	 * @param newPassword
	 * @param response
	 */
	public void modifyPassword(String userNo,String oldPassword,String newPassword,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.MODIFY_PASSWORD);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.MODIFY_PASSWORD);
		ModifyPasswordParams request = new ModifyPasswordParams();
		request.setUserNo(userNo);
		request.setOldPassword(CommonUtil.getMD5(oldPassword));
		request.setNewPassword(CommonUtil.getMD5(newPassword));
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(request));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	
	/**
	 * 第三方登录
	 * @param source
	 * @param sourceId
	 * @param response
	 */
	public void thirdLogin(int source, String sourceId,String nick,int sex,String url,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.THRID_LOGIN);
		ThirdLoginParams loginParams = new ThirdLoginParams();
		loginParams.setSource(source);
		loginParams.setSourceId(sourceId);
		loginParams.setTsUserId(BaseApplication.mPushUserId);
		loginParams.setRole(CONSTANT.USER_ROLE_TEACHER);
		loginParams.setMediaSource(CONSTANT.MEDIA_SOURCE_ANDROID);
		loginParams.setEquipId(CommonUtil.getIMEI());
		loginParams.buildUser(nick, sex, url);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(loginParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 查询个人详细资料
	 * @param userNo
	 * @param response
	 */
	public void getUserInfo(String userNo,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.USER_INFO);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.GET_USER_INFO);
        UserNoParams userNoParams = new UserNoParams();
        userNoParams.setUserNo(userNo);
        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(userNoParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
//	/**
//	 * 更新用户资料
//	 * @param userNo
//	 * @param key多个以逗号分隔
//	 * @param value
//	 * @param response
//	 */
//	public void updateUserInfo(String userNo,String key,String value,int type,ResponseHandlerInterface response){
//		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.UPDATE_USER_INFO);
//        UpdateUserParams request = new UpdateUserParams();
//        
//        request.userNo = userNo;
//        if (!TextUtils.isEmpty(key)) {
//        	request.key = key.split(",");
//		}
//        if (!TextUtils.isEmpty(value)) {
//			String [] values = value.split(",");
//			int length = values.length;
//			if (type == CONSTANT.UPDATE_TYPE_DIC) {//字典格式
//				DicMap[] maps = new DicMap[length];
//				for (int i = 0; i < length; i++) {
//					maps[i] = new DicMap(Integer.parseInt(values[i]), "");
//				}
//				request.value = maps;
//			}else{
//				request.value = values;
//			}
//		}
//        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(request));
//		mAsyncHttpClient.post(CONSTANT.WEBHOST,params,response);
//	}
	
	/**
	 * 更新用户资料
	 * @param userNo
	 * @param key多个以逗号分隔
	 * @param value
	 * @param response
	 */
	public void updateUserInfo(String userNo,String key,String value,int type,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.UPDATE_USER_INFO);
        if (type == CONSTANT.UPDATE_TYPE_DIC) {
        	UpdateUserDicParams request = new UpdateUserDicParams();
        	request.userNo = userNo;
            request.key = key;
        	request.value = new DicMap(Integer.parseInt(value), "");
        	CommonUtil.umengEvent(CONSTANT.EVENT_ID.UPDATE_USER,request.key,request.key);
        	 params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(request));
		}else if (type == CONSTANT.UPDATE_TYPE_STRING){
			UpdateUserStringParams request = new UpdateUserStringParams();
			request.userNo = userNo;
	        request.key = key;
	        request.value = value;
	        CommonUtil.umengEvent(CONSTANT.EVENT_ID.UPDATE_USER,request.key,request.key);
	        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(request));
		}else if (type == CONSTANT.UPDATE_TYPE_INT){
			UpdateUserIntegerParams request = new UpdateUserIntegerParams();
			request.userNo = userNo;
	        request.key = key;
	        request.value = Integer.parseInt(value);
	        CommonUtil.umengEvent(CONSTANT.EVENT_ID.UPDATE_USER,request.key,request.key);
	        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(request));
			
		}
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 更新学校和地址方法
	 * @param userNo
	 * @param province
	 * @param city
	 * @param county
	 * @param schoolCode
	 * @param schoolName
	 * @param response
	 */
	public void updateAddressSchool(String userNo,DicMap province,DicMap city,DicMap county,String schoolCode,String schoolName,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.UPDATE_USER_INFO);
        UpdateUserParams request = new UpdateUserParams();
        request.userNo = userNo;
        if (province == null) {//只修改学校
        	request.key = "county,schoolCode,schoolName".split(",");
		}else{
			request.key = "province,city,county,schoolCode,schoolName".split(",");
		}
        int length = request.key.length;
        Object [] obj = new Object[length];
        if (length == 3) {
        	obj[0] = county;
            obj[1] = schoolCode;
            obj[2] = schoolName;
		}else{
			obj[0] = province;
			obj[1] = city;
			obj[2] = county;
	        obj[3] = schoolCode+"";
	        obj[4] = schoolName;
		}
		request.value = obj;
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.UPDATE_USER,"school","school");
        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(request));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**获取活动列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getActiveList(String userNo,int start,int limit,String word,List<Conds> conds,int isAdt,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.ACTIVE_LIST);
		CommonAdsListParams entityParams = new CommonAdsListParams();
		entityParams.setStart(start);
		entityParams.setLimit(limit);
		entityParams.isAdt = isAdt;
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取活动详情
	 * @param userNo
	 * @param actId
	 * @param response
	 */
	public void getActiveDetail(String userNo,int actId,String groupId,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.ACTIVE_DETAIL);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.ACTIVE_DETAIL);
		ActiveDetailParams entityParam = new ActiveDetailParams();
		entityParam.userNo = userNo;
		entityParam.actId = actId;
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	/**
	 * 活动报名
	 * @param userNo
	 * @param actId
	 * @param userName
	 * @param mobile
	 * @param email
	 * @param response
	 */
	public void activeApply(String userNo,int actId,String userName,String mobile,String email,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.ACTIVE_APPLY);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.ACTIVE_APPLY);
		ActiveApplyParams entityParam = new ActiveApplyParams();
		entityParam.userNo = userNo;
		entityParam.actId = actId;
		entityParam.userName = userName;
		entityParam.mobile = mobile;
		entityParam.email = email;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	/**
	 * 获取活动分类
	 * @param userNo
	 * @param response
	 */
	public void getActiveCategory(String userNo,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.ACTIVE_CAGEGORY);
		ActiveCategoryParams entityParam = new ActiveCategoryParams();
		entityParam.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取微课列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getWeikeList(String userNo,int start,int limit,String word,List<Conds> conds,int isAdt,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.WEIKE_LIST);
		CommonAdsListParams entityParams = new CommonAdsListParams();
		entityParams.setStart(start);
		entityParams.isAdt = isAdt;
		entityParams.setLimit(limit);
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取微课详情
	 * @param userNo
	 * @param coseId
	 * @param response
	 */
	public void getWeikeDetail(String userNo,int coseId,String groupId,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.WEIKE_DETAIL);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.WEIKE_DETAIL);
		WeikeDetailParams entityParam = new WeikeDetailParams();
		entityParam.userNo = userNo;
		entityParam.coseId = coseId;
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 吐槽广场列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param isTop
	 * @param response
	 */
	public void getCommunityList(String userNo,int start,int limit,String word,List<Conds> conds,int isTop,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_LIST);
		CommunityListParams entityParams = new CommunityListParams();
		entityParams.start = start;
		entityParams.limit = limit;
		entityParams.isTop = isTop;
		entityParams.conds = conds;
		entityParams.userNo = userNo;
		entityParams.word = word;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取吐槽详情
	 * @param userNo
	 * @param coseId
	 * @param response
	 */
	public void getCommunityDetail(String userNo,int tcId,String groupId,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMUNITY_DETAIL);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_DETAIL);
		CommunityDetailParams entityParam = new CommunityDetailParams();
		entityParam.userNo = userNo;
		entityParam.tcId = tcId;
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取吐槽评论列表
	 * @param userNo
	 * @param coseId
	 * @param response
	 */
	public void getCommentList(String userNo,int tcId,int start,int limit,String word,List<Conds> conds,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_COMMENT_LIST);
		CommentListParams entityParam = new CommentListParams();
		entityParam.setUserNo(userNo);
		entityParam.tcId = tcId;
		entityParam.setStart(start);
		entityParam.setLimit(limit);
		entityParam.setConds(conds);
		entityParam.setUserNo(userNo);
		entityParam.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 我的吐槽列表
	 * @param userNo
	 * @param mGroupId 
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getMyCommunityList(String userNo,String toUserNo,String mGroupId, int start,int limit,String word,List<Conds> conds,boolean isUser,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.MY_COMMUNITY);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.MY_COMMUNITY);
		MyCommunityListParams entityParams = new MyCommunityListParams();
		entityParams.isUser = isUser?1:0;
		entityParams.setStart(start);
		entityParams.toUserNo = toUserNo;
		entityParams.setLimit(limit);
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		if(mGroupId != null && !TextUtils.isEmpty(mGroupId)) {
			params.put(CONSTANT.PARAMS.GROUP_ID, mGroupId);
		}
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 我的吐槽消息列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getCommunityMessageList(String userNo,int start,int limit,String word,List<Conds> conds,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMUNITY_MESSAGE);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_MESSAGE_LIST);
		CommonListParams entityParams = new CommonListParams();
		entityParams.setStart(start);
		entityParams.setLimit(limit);
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 我的吐槽消息已读
	 * @param userNo
	 * @param response
	 */
	public void readCommunityMessage(String userNo,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_MESSAGE_READ);
		MessageReadParams entityParams = new MessageReadParams();
		entityParams.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 发布吐槽
	 * @param userNo
	 * @param content
	 * @param isAnous
	 * @param address
	 * @param idxes
	 * @param response
	 */
	public void createCommunity(String userNo,String content,int isAnous,Address address,String[] qnIds,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMUNITY_PUBLISH);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.CREATE_COMMUNITY);
		CreateCommunityParams entityParams = new CreateCommunityParams();
		entityParams.userNo = userNo;
		entityParams.content = content;
		entityParams.isAnous = isAnous;
		if (address != null) {
			entityParams.address = address;
		}
		entityParams.qnIds = qnIds;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	/**
	 * 删除吐槽
	 * @param userNo
	 * @param tcId
	 * @param mGroupId 
	 * @param response
	 */
	public void deleteCommunity(String userNo,int tcId,String mGroupId, ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMUNITY_DELETE);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.DELETE_COMMUNITY);
		DeleteComnunityParams entityParams = new DeleteComnunityParams();
		entityParams.userNo = userNo;
		entityParams.tcId = tcId;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, mGroupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 吐槽评论
	 * @param userNo
	 * @param toUserNo
	 * @param tcId
	 * @param content
	 * @param response
	 */
	public void createComment(String userNo,String toUserNo,int tcId,int tcComId,String content,String groupId,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMUNITY_COMMENT);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_COMMENT);
		CreateCommentParams entityParams = new CreateCommentParams();
		entityParams.userNo = userNo;
		entityParams.content = content;
		entityParams.tcComId =tcComId;
		entityParams.tcId = tcId;
		entityParams.toUserNo = toUserNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 删除评论
	 * @param userNo
	 * @param tcComId
	 * @param response
	 */
	public void deleteComment(String userNo,int tcComId,String groupId,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMENT_DELETE);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.COMMUNITY_COMMENT_DELETE);
		DeleteCommentParams entityParams = new DeleteCommentParams();
		entityParams.userNo = userNo;
		entityParams.tcComId =tcComId;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取系统消息列表
	 * @param userNo
	 * @param word
	 * @param queryConds
	 * @param response
	 */
	public void getMessageList(String userNo,int start,int limit,String word,List<Conds> conds,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.SYS_MESSAGE);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.SYSTEM_MESSAGE_LIST);
		MessageListParams entityParam = new MessageListParams();
		entityParam.setConds(conds);
		entityParam.setStart(start);
		entityParam.setLimit(limit);
		entityParam.setUserNo(userNo);
		entityParam.setWord(word);
		entityParam.equipId = CommonUtil.getIMEI();
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParam));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	/**
	 * 系统消息已读接口
	 * @param userNo
	 * @param sysMId
	 * @param response
	 */
	public void messageRead(String userNo,int sysMId,String groupId,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.SYSTEM_MESSAGE_READ);
		SysMessageReadParams messageReadParams = new SysMessageReadParams();
		messageReadParams.setUserNo(userNo);
		messageReadParams.setSysMId(sysMId);
		messageReadParams.equipId = CommonUtil.getIMEI();
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(messageReadParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取消息明细接口
	 * @param userNo
	 * @param sysMId
	 * @param response
	 */
	public void messageDetail(String userNo,int sysMId,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.MESSAGE_DETAIL);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.SYSTEM_MESSAGE_DETAIL);
		SysMessageReadParams messageReadParams = new SysMessageReadParams();
		messageReadParams.setUserNo(userNo);
		messageReadParams.setSysMId(sysMId);
		messageReadParams.equipId = CommonUtil.getIMEI();
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(messageReadParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 提交反馈
	 * @param userNo
	 * @param type 1，意见，2 投诉
	 * @param content
	 * @param response
	 */
	public void feedback(String userNo,int type,String content,String contact,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.FEEDBACK);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.COMMIT_FEEDBACK);
        FeedbackParams feedbackParams = new FeedbackParams();
        feedbackParams.userNo = userNo;
        feedbackParams.type = type;
        feedbackParams.content = content;
        feedbackParams.contact = contact;
        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(feedbackParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 获取七牛服务器 的上传token
	 * @param userNo
	 * @param response
	 */
	public void getQiniuToken(String userNo,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GET_QINIU_TOKEN);
		UserNoParams userNoToken = new UserNoParams();
		userNoToken.setUserNo(userNo);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(userNoToken));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 点赞/取消点赞
	 * @param userNo
	 * @param assoType
	 * @param assoId
	 * @param isPraise 1-是，2-否
	 * @param response
	 */
	public void loveAction(String userNo,int assoType,int assoId,int isPraise,String groupId,ResponseHandlerInterface response){
		String key = isPraise == CONSTANT.IS_PRISED ?"love":"unlove";
		switch (assoType) {
		case CONSTANT.ASSO_TYPE_ACTIVE:
			CommonUtil.umengEvent(CONSTANT.EVENT_ID.ACTIVE_LOVE,key,key);
			break;
		case CONSTANT.ASSO_TYPE_WEIKE:
			CommonUtil.umengEvent(CONSTANT.EVENT_ID.WEIKE_LOVE,key,key);
			break;
		case CONSTANT.ASSO_TYPE_COMMUNITY:
			CommonUtil.umengEvent(CONSTANT.EVENT_ID.COMMUNITY_LOVE,key,key);
			break;
		default:
			break;
		}
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.LOVE_ACTOIN);
		LoveActionParams entityParams = new LoveActionParams();
		entityParams.userNo = userNo;
		entityParams.assoType = assoType;
		entityParams.assoId = assoId;
		entityParams.isPraise = isPraise;
		entityParams.mediaSource = CONSTANT.MEDIA_SOURCE_ANDROID;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 浏览
	 * @param userNo
	 * @param assoType
	 * @param assoId
	 * @param response
	 */
	public void viewAction(String userNo,int assoType,int assoId,String groupId,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.VIEW_ACTION);
		ViewActionParams entityParams = new ViewActionParams();
		entityParams.userNo = userNo;
		entityParams.assoType = assoType;
		entityParams.assoId = assoId;
		entityParams.equipId = CommonUtil.getIMEI();
		entityParams.mediaSource = CONSTANT.MEDIA_SOURCE_ANDROID;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 
	 * 视频播放次数
	 * @param userNo
	 * @param assoType
	 * @param assoId
	 * @param isPraise 1-是，2-否
	 * @param response
	 */
	public void playAction(String userNo,int assoType,int assoId,String groupId,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.PLAY_VIDEO);
		ViewActionParams entityParams = new ViewActionParams();
		entityParams.userNo = userNo;
		entityParams.assoType = assoType;
		entityParams.assoId = assoId;
		entityParams.equipId = CommonUtil.getIMEI();
		entityParams.mediaSource = CONSTANT.MEDIA_SOURCE_ANDROID;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		params.put(CONSTANT.PARAMS.GROUP_ID, groupId);
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**
	 * 绑定手机号
	 * @param mobile
	 * @param validateno
	 * @param role
	 * @param response
	 */
	public void bindMobile(String mobile,String validateNo,int role,String smsId,String pwd,ResponseHandlerInterface response){
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.BIND_MOBILE);
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.BIND_MOBILE);
        BindMobileParams entityParams = new BindMobileParams();
        entityParams.setUserNo(BaseApplication.mUserNo);
        entityParams.setMobile(mobile);
        entityParams.smsId = smsId;
        entityParams.type = CONSTANT.VALIDATE_NO_TYPE_REGIST;
        entityParams.setValidateNo(validateNo);
        entityParams.setRole(CONSTANT.USER_ROLE_TEACHER);
        entityParams.password = CommonUtil.getMD5(pwd);
        entityParams.interVer = "8437536c7728fccf89f7fd306d85c07b";
        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	/**
	 * 注销
	 * @param userNo
	 */
//	public void logout(String userNo,ResponseHandlerInterface response){
//		CommonUtil.umengEvent(CONSTANT.EVENT_ID.LOGOUT);
//		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.LOGOUT);
//		UserNoParams entityParams = new UserNoParams();
//		entityParams.setUserNo(userNo);
//		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
//		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
//	}
	
	/**
	 * 查询地址接口
	 * @param userNo
	 * @param type
	 * @param lastCode
	 * @param response
	 */
	public void queryAddress(String userNo,String type,int lastCode,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.QUERY_ADDRESS);
		QueryAddressParams entityParams = new QueryAddressParams();
		entityParams.userNo = userNo;
		entityParams.area = type;
		entityParams.lastCode = lastCode;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	/**
	 * 查询学校
	 * @param userNo
	 * @param areaCode
	 * @param type
	 * @param response
	 */
	public void querySchool(String userNo,int areaCode,int type,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.QUERY_SCHOOL);
		QuerySchoolParams entityParams = new QuerySchoolParams();
		entityParams.userNo = userNo;
		entityParams.areaCode = areaCode;
		entityParams.type = type;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	public void fileUpload(String filePath, ResponseHandlerInterface response) {
		CommonUtil.umengEvent(CONSTANT.EVENT_ID.FILE_UPLOAD);
        RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE, CONSTANT.EVENT_TYPE.FILE_UPLOAD);
        UserNoParams entityParams = new UserNoParams();
        entityParams.setUserNo(BaseApplication.mUserNo);
        params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
        try {
//            String thumbUploadPath = BitmapUtil.getThumbUploadPath(path, fileName, 640);
            File file = new File(filePath);
            params.put("upload", file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        LogUtil.i(params.toString());
        mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE, params, response);
    }
	
	/**获取群组列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getGroupList(String userNo,int start,int limit,String word,List<Conds> conds,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_LIST);
		CommonListParams entityParams = new CommonListParams();
		entityParams.setStart(start);
		entityParams.setLimit(limit);
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**获取已加入的群组列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getJoinList(String userNo,int start,int limit,String word,List<Conds> conds,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_JOIN);
		CommonListParams entityParams = new CommonListParams();
		entityParams.setStart(start);
		entityParams.setLimit(limit);
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**获取推荐列表
	 * @param userNo
	 * @param start
	 * @param limit
	 * @param word
	 * @param conds
	 * @param response
	 */
	public void getRecommendGroupList(String userNo,int start,int limit,String word,List<Conds> conds,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GRUOP_RECOMMEND_LIST);
		CommonListParams entityParams = new CommonListParams();
		entityParams.setStart(start);
		entityParams.setLimit(limit);
		entityParams.setConds(conds);
		entityParams.setUserNo(userNo);
		entityParams.setWord(word);
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**获取分组详情
	 * @param userNo
	 * @param groupId
	 */
	public void getGroupDetail(String userNo,String groupId,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_DETAIL);
		GroupProfileParams entityParams = new GroupProfileParams();
		entityParams.groupId = groupId;
		entityParams.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**加入群组
	 * @param userNo
	 * @param groupId
	 */
	public void groupApply(String userNo,String groupId,String remark,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_APPLY);
		GroupProfileParams entityParams = new GroupProfileParams();
		entityParams.groupId = groupId;
		entityParams.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**退出群组
	 * @param userNo
	 * @param groupId
	 */
	public void groupExit(String userNo,String groupId,String remark,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_EXIT);
		GroupProfileParams entityParams = new GroupProfileParams();
		entityParams.groupId = groupId;
		entityParams.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**获取官方群组
	 * @param userNo
	 */
	public void officialGroup(String userNo,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_OFFICIAL);
		GroupSelectParams entityParams = new GroupSelectParams();
		entityParams.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	/**选择群组页面接口
	 * @param userNo
	 */
	public void selectGroup(String userNo,ResponseHandlerInterface response){
		RequestParams params = new RequestParams(CONSTANT.PARAMS.EVENTTYPE,CONSTANT.EVENT_TYPE.GROUP_SELECT);
		GroupSelectParams entityParams = new GroupSelectParams();
		entityParams.userNo = userNo;
		params.put(CONSTANT.PARAMS.ENTITY, mGson.toJson(entityParams));
		mAsyncHttpClient.post(CONSTANT.WEBHOST_MOBILE,params,response);
	}
	
	
	
}
